<template>
  <a-space>
    <!-- <span
      style="
        background-color: rgb(245, 221, 178);
        padding: 5px;
        min-width: 50px;
        text-align: center;
      "
      >{{ lengthsis }}行</span
    > -->
    <div
      @click="click(item)"
      class="toolbar-item"
      v-for="(item, index) in (items as string[])"
      :key="index"
    >
      <!-- <span v-if="item !== '导入'">{{ item }}</span> -->
      <!-- <el-button v-if="item !== '导入'" :icon="Search" circle /> -->
      <el-button
        v-if="item == '查询' || item == '查询参数' || item == '查询助剂信息'"
        type="primary"
      >
        <el-icon style="margin-right: 5px" :size="18" color="#fff">
          <Search />
        </el-icon>
        {{ item }}
      </el-button>
      <el-button
        v-else-if="
          item == '新增' ||
          item == '新增产品基础资料' ||
          item == '新增原料入库' ||
          item == '新增(采购单)' ||
          item == '新增(原纱仓)' ||
          item == '新增(领料单)' ||
          item == '新增(布笼)' ||
          item == '新增结算类型' ||
          item == '创建需求单' ||
          item == '新建调拨单' ||
          item == '创建修补单' ||
          item == '新建出库单' ||
          item == '新增针盘' ||
          item == '需求单创建申购单' ||
          item == '创建申购单' ||
          item == '创建采购单' ||
          item == '添加物料' ||
          item == '创建拆纱单' ||
          item == '调拨单申请' ||
          item == '调拨申请' ||
          item == '添加染化料信息' ||
          item == '添加工艺步骤' ||
          item == '添加参数' ||
          item == '添加程序号' ||
          item == '助剂信息录入' ||
          item == '需求单汇总' ||
          item == '新增检查内容' ||
          item == '新增调机单' ||
          item == '新增报废'
        "
        type="success"
        :icon="CirclePlus"
        >{{ item }}
      </el-button>
      <el-button v-else-if="item == '删除'" :icon="Delete" plain>{{ item }}</el-button>
      <el-button v-else-if="item == '导出'" :icon="Upload" plain>{{ item }}</el-button>
      <el-button v-else-if="item == '全部导出'" :icon="Upload" plain>{{ item }}</el-button>
      <span v-else-if="item == '导入'">
        <el-button :icon="Download" plain @click="download">模板下载</el-button>
        <el-button :icon="Download" @click="click1" plain>导入Excel</el-button>
      </span>
      <el-button v-else-if="item == '导入初始化'" :icon="Download" @click="click1" plain
        >{{ item }}
      </el-button>
      <el-button v-else-if="item == '导入Excel'" :icon="Download" @click="click1" plain
        >{{ item }}
      </el-button>
      <!-- <el-button v-else-if="item == '模板下载'" :icon="Download" @click="download" plain>{{
        item
      }}</el-button> -->
      <el-button v-else-if="item == '重置密码'" :icon="Stamp" plain type="danger">{{
        item
      }}</el-button>
      <el-button v-else-if="item == '提交'" :icon="Check" plain>{{ item }}</el-button>
      <el-button v-else-if="item == '打印'" :icon="Printer" plain>{{ item }}</el-button>
      <el-button v-else-if="item == '变更单打印'" :icon="Printer" plain>{{ item }}</el-button>
      <el-button v-else-if="item == '打印明细'" :icon="Printer" plain>{{ item }}</el-button>
      <el-button v-else-if="item == '打印统计'" :icon="Printer" plain>{{ item }}</el-button>
      <el-button v-else-if="item == '复制'" :icon="CopyDocument" plain>{{ item }}</el-button>
      <el-button v-else-if="item == '审核'" :icon="Stamp" plain>{{ item }}</el-button>
      <el-button v-else-if="item == '提交厂长审核'" :icon="Stamp" plain>{{ item }}</el-button>
      <el-button v-else-if="item == '反审'" :icon="EditPen" plain>{{ item }}</el-button>
      <el-button v-else-if="item == '取消审核'" :icon="EditPen" plain>{{ item }}</el-button>
      <el-button v-else-if="item == '驳回'" plain>
        <el-icon style="margin-right: 5px" :size="20" color="#f56c6c">
          <Warning />
        </el-icon>
        {{ item }}
      </el-button>
      <el-button v-else-if="item != '' && item != '模板下载'" plain>{{ item }}</el-button>
      <!-- <a-dropdown v-else-if="item == '导入'">
        <span>导入</span>
        <template #content>
          <a-doption @click="click1">导入Excel</a-doption>
          <a-doption @click="download">模板下载</a-doption>
        </template>
      </a-dropdown> -->

      <!-- <a-divider v-if="items.length >= index + 2" direction="vertical" /> -->
    </div>
  </a-space>
</template>

<script lang="ts">
  import emitter from '@/hooks/useEventBus'
  import {
    Upload,
    Search,
    CirclePlus,
    Download,
    Delete,
    Check,
    Printer,
    CopyDocument,
    EditPen,
    Warning,
    Stamp,
  } from '@element-plus/icons-vue'

  export default {
    name: 'Toolbar',
    emits: [
      'close',
      'open',
      'add',
      'edit',
      'del',
      'cel',
      'export',
      'exportAll',
      'exportToday',
      'import',
      'select',
      'flycloth',
      'print',
      'paper',
      'init',
      'picking',
      'counter',
      'yupaic',
      'paic',
      'excel',
      'dyBoufei',
      'dyWork',
      'dyNormal',
      'dyFeed',
      'saveData',
      'repairData',
      'downgradeData',
      'openPop',
      'closePop',
      'rejected',
      'audit',
      'tj',
      'qxtj',
      'tjWl',
      'selectSOP',
      'delQk',
      'addXqiu',
      'cjxqd',
      'cjxlk',
      'zbtzd',
      'cjCg',
      'cjYl',
      'cshck',
      'downloadAppN',
      'downloadAppW',
      'downloadApp',
      'xzlld',
      'cjcsd',
      'ktktk',
      'printBgd',
      'printWjg',
      'dycsd',
      'dysf',
      'bdsf',
      'zbtzd',
      'cjCg',
      'cjYl',
      'cshck',
      'downloadApp',
      'xzlld',
      'chuangjianlinliaodan',
      'dabao',
      'xinzhuojia',
      'copy',
      'fexDel',
      'selectcsg',
      'fhzy',
      'reders',
      'handle',
      'addZgyds',
      'printGy',
      'gaigongyi',
      'gaiyanse',
      'gongyiyanse',
      'createPatchOrder',
      'cjtld',
      'complete',
      'oders',
      'addDb',
      'xzzp',
      'xzylRk',
      'addCk',
      'addRk',
      'compute',
      'deletZp',
      'shaping',
      'aiding',
      'xqHuiz',
      'xuCreatego',
      'Creatego',
      'CreateCai',
      'Rparameter',
      'addAoutSet',
      'dispatch',
      'checkInMonitor',
      'addyeing',
      'addSteps',
      'IpInitialization',
      'printPhyLabel',
      'printSmLabel',
      'split',
      'repair',
      'cancelSuspend',
      'suspend',
      'printArrangCard',
      'scanDyePart',
      'setFast',
      'cancelFast',
      'setHOLD',
      'cancelHOLD',
      'farmProgress',
      'updateData',
      'ChangeButton',
      'addParameterValue',
      'addaids',
      'addNumbers',
      'printQRCode',
      'CountBath',
      'theEnd',
      'flowCardCopy',
      'formulaOddCopy',
      'ImportBroker',
      'downloadAppQrcode',
      'Retest',
      'dyBoufeix',
      'returnList',
      'kzbds',
      'xuqiudanhuiz',
      'Unlock',
      'tihuan',
      'buDa',
      'MdButton',
      'ResetPwd',
      'paichanx',
      'zbtzdDj',
      'zjjt',
      'zjt',
      'zt',
      'qxzt',
      'xzgzckd',
      'tyblmbxz',
      'imports',
      'sdpc',
      'zdpc',
      'clsm',
      'printTJ',
      'printMX',
      'sendSwitch',
      'alLocationApply',
      'dutyDecide',
      'enable',
      'deactivate',
      'addScrap',
     
    ],
    props: {
      items: {
        type: Array,
        required: true,
      },
      totalssss: {
        type: Number,
        default: 0,
      },
    },
    setup(props, ctx) {
      const click = (e: string) => {
        if (e === '导入') {
          return
        }
        switch (e) {
          case '新增':
            ctx.emit('add')
            break
          case '修改':
            ctx.emit('edit')
            break
          case '删除':
            ctx.emit('del')
            break
          case '终止解锁':
          case '终止盘点':
          case '作废':
            ctx.emit('cel')
            break
          case '导出':
          case '导出清单':
            ctx.emit('export')
            break
          case '全部导出':
            ctx.emit('exportAll')
            break
            case '导出当日结存':
            ctx.emit('exportToday')
            break
          case '导入初始化':
            ctx.emit('IpInitialization')
            break
          case '导入':
          case '导入差异':
            ctx.emit('import')
            break
          case '打印布飞':
            ctx.emit('flycloth')
            break
          case '打印机台纸':
            ctx.emit('paper')
            break
          case '开需求单':
            ctx.emit('picking')
            break
          case '反审':
            ctx.emit('counter')
            break
          case '预排产':
            ctx.emit('yupaic')
            break
          case '排产':
            ctx.emit('paic')
            break
          case '查询':
            ctx.emit('select')
            break
          case '打印':
            ctx.emit('dyBoufei')
            ctx.emit('print')
            break
          case '套打染部工作单':
            ctx.emit('dyWork')
            break
          case '打印正常单':
            ctx.emit('dyNormal')
            break
          case '打印加料单':
            ctx.emit('dyFeed')
            break
          case '保存':
            ctx.emit('saveData')
            break
          case '修补':
            ctx.emit('repairData')
            break
          case '降等':
            ctx.emit('downgradeData')
            break
          case '展开':
            ctx.emit('openPop')
            break
          case '关闭':
            ctx.emit('closePop')
          case '驳回':
            ctx.emit('rejected')
            break
          case '审核':
            case'提交厂长审核':
            ctx.emit('audit')
            break
          case '取消审核':
            ctx.emit('cancelAudit')
            break
          case '提交':
            ctx.emit('tj')
            break
          case '取消提交':
            ctx.emit('qxtj')
            break
          case '添加物料':
            ctx.emit('tjWl')
            break
          case '新增检查内容':
            ctx.emit('selectSOP')
            break
          case '清空':
            ctx.emit('delQk')
            break
          case '确认':
            ctx.emit('addXqiu')
            break
          case '创建需求单':
            ctx.emit('cjxqd')
            break
          case '创建下拉框':
            ctx.emit('cjxlk')
            break
          case '织布通知单':
            ctx.emit('zbtzd')
            break
          case '新增(采购单)':
            ctx.emit('cjCg')
            break
          case '新增(原纱仓)':
            ctx.emit('cjYl')
            break
          case '委外加工':
            ctx.emit('oem')
            break
          case '初始化仓库':
            ctx.emit('cshck')
            break
          case '下载安装包':
            ctx.emit('downloadApp')
            break
          case '下载':
            ctx.emit('download')
            break
          case '退库':
            ctx.emit('ktktk')
            break
          case '变更单打印':
          case '本集团打印':
            ctx.emit('printBgd')
            break  
            case '外加工打印':
            ctx.emit('printWjg')
            break
          case '新增(领料单)':
            ctx.emit('xzlld')
            break  
          case '创建拆纱单':
            ctx.emit('cjcsd')
            break
          case '打印拆纱单':
            ctx.emit('dycsd')
            break
          case '打印纱飞':
            ctx.emit('dysf')
            break
          case '补打纱飞':
            ctx.emit('bdsf')
          case '创建领料单':
            ctx.emit('chuangjianlinliaodan')
            break
          case '打包':
            ctx.emit('dabao')
            break
          case '初始化':
            ctx.emit('init')
            break
          case '新增(布笼)':
            ctx.emit('xinzhuojia')
            break
          case '返回主页':
            ctx.emit('fhzy')
            break
          case '复制':
            ctx.emit('copy')
            break
          case '创建盘点单':
            ctx.emit('init')
            break
          case '作废':
            ctx.emit('fexDel')
            break
          case '选择拆纱工':
            ctx.emit('selectcsg')
            break
          case '入库':
            ctx.emit('reders')
            break
          case '处理':
            ctx.emit('handle')
            break
          case '开织造工艺单':
            ctx.emit('addZgyds')
            break
          case '打印工艺单':
            ctx.emit('printGy')
            break
          case '复制(工艺)':
            ctx.emit('gaigongyi')
            break
          case '复制(颜色)':
            ctx.emit('gaiyanse')
            break
          case '复制(工艺颜色)':
            ctx.emit('gongyiyanse')
          case '创建修补单':
            ctx.emit('createPatchOrder')
            break
          case '创建退料单':
            ctx.emit('cjtld')
            break
          case '完成':
            ctx.emit('complete')
            break
          case '出库':
            ctx.emit('oders')
            break
          case '新建调拨单':
            ctx.emit('addDb')
            break
          case '新增针盘':
            ctx.emit('xzzp')
            break
          case '新增原料入库':
            ctx.emit('xzylRk')
            break
          case '新建出库单':
            ctx.emit('addCk')
            break
          case '新建入库单':
            ctx.emit('addRk')
            break
          case '计算':
            ctx.emit('compute')
            break
          case '清空针盘':
            ctx.emit('deletZp')
            break
          case '定型工艺维护':
            ctx.emit('shaping')
            break
          case '定型助剂维护':
            ctx.emit('aiding')
            break
          case '单据汇总':
            ctx.emit('xqHuiz')
            break
          case '需求单创建申购单':
            ctx.emit('xuCreatego')
            break
          case '创建申购单':
            ctx.emit('Creatego')
            break
          case '创建采购单':
            ctx.emit('CreateCai')
            break
          case '查询参数':
            ctx.emit('Rparameter')
            break
          case '调拨单申请':
            ctx.emit('addAoutSet')
            break
          case '派工':
            ctx.emit('dispatch')
            break
          case '值机班长确认':
            ctx.emit('checkInMonitor')
            break
          case '调机发布':
            ctx.emit('checkInMonitor')
            break
          case '转单发布':
            ctx.emit('sendSwitch')
            break
          case '添加染化料信息':
            ctx.emit('addyeing')
            break
          case '添加工艺步骤':
            ctx.emit('addSteps')
            break
          case '添加参数':
            ctx.emit('addParameterValue')
            break
          case '助剂信息录入':
            ctx.emit('addaids')
            break
          case '添加程序号':
            ctx.emit('addNumbers')
            break
          case '计算浴比':
            ctx.emit('CountBath')
            break
          case '流转卡号拷贝':
            ctx.emit('flowCardCopy')
            break
          case '配方单号拷贝':
            ctx.emit('formulaOddCopy')
            break
          case '导入中转站':
            ctx.emit('ImportBroker')
            break
          case '批量归还':
            ctx.emit('returnList')
            break
          case '打印物测标签':
            ctx.emit('printPhyLabel')
            break
          case '打印小标签':
            ctx.emit('printSmLabel')
          case '拆分':
            ctx.emit('split')
          case '回修':
            ctx.emit('repair')
          case '取消终止':
            ctx.emit('cancelSuspend')
            break
          case '缸卡终止':
            ctx.emit('suspend')
            break
          case '打印排缸卡':
            ctx.emit('printArrangCard')
          case '染部收单扫描':
            ctx.emit('scanDyePart')
          case '设置快反':
            ctx.emit('setFast')
          case '取消快反':
            ctx.emit('cancelFast')
          case 'HOLD单':
            ctx.emit('setHOLD')
          case 'HOLD取消':
            ctx.emit('cancelHOLD')
          case '车间进度':
            ctx.emit('farmProgress')
          case '更新数据':
            ctx.emit('updateData')
          case '变更':
            ctx.emit('ChangeButton')
          case '打印二维码':
            ctx.emit('printQRCode')
          case '完结':
            ctx.emit('theEnd')
          case '下载二维码':
            ctx.emit('downloadAppQrcode')
          case '重测':
            ctx.emit('Retest')
          case '打印布飞(新)':
            ctx.emit('dyBoufeix')
            break
          case '开增补单':
            ctx.emit('kzbds')
            break
          case '需求单汇总':
            ctx.emit('xuqiudanhuiz')
          case '解锁':
            ctx.emit('Unlock')
          case '替换':
            ctx.emit('tihuan')
          case '补打':
            ctx.emit('buDa')
          case '码单打印':
            ctx.emit('MdButton')
            break
          case '重置密码':
            ctx.emit('ResetPwd')
            break
          case '排产(新)':
            ctx.emit('paichanx')
            break
          case '织布通知单(对接订单模版)':
            ctx.emit('zbtzdDj')
            break
          case '增加机台':
            ctx.emit('zjjt')
            break
          case '转机台':
            ctx.emit('zjt')
            break
          case '暂停':
            ctx.emit('zt')
            break
          case '取消暂停':
            ctx.emit('qxzt')
            break
          case '新增固资出库单':
            ctx.emit('xzgzckd')
            break
          case '通用布笼模板下载':
            ctx.emit('tyblmbxz')
            break
          case '通用布笼模板导入':
            ctx.emit('imports')
            break
          case '手动排产':
            ctx.emit('sdpc')
            break
          case '自动排产':
            ctx.emit('zdpc')
            break
          case '产量扫描':
            ctx.emit('clsm')
            break
          case '打印统计':
            ctx.emit('printTJ')
            break
          case '打印明细':
            ctx.emit('printMX')
            break
          case '取消排产':
            ctx.emit('qxPc')
            break
          case '调拨申请':
            ctx.emit('alLocationApply')
            break
          case '新增调机单':
            ctx.emit('addTj')
            break
          case '洗机预警天数':
            ctx.emit('washMachinePredictDays')
            break
          case '责任判定':
            ctx.emit('dutyDecide')
            break
          case '启用':
            ctx.emit('enable')
            break
          case '停用':
            ctx.emit('deactivate')
            break
          case '新增报废':
            ctx.emit('addScrap')
            break
          default:
            break
        }
      }
      const click2 = (e: string) => {
        if (e === '收起') {
          props.items.splice(props.items.indexOf('收起'), 1, '展开')
          props.items.length = 0
          ctx.emit('close')
        } else {
          props.items.splice(props.items.indexOf('展开'), 1, '收起')
          ctx.emit('open')
        }
      }
      const click1 = () => {
        ctx.emit('import')
      }
      const download = () => {
        ctx.emit('excel')
      }
      const clickApp = () => {
        ctx.emit('downloadApp')
      }
      // const lengthsis = ref(0)
      // emitter.on('lenghensssss', (leng: any) => {
      //   lengthsis.value = leng
      //   console.log('按钮', lengthsis.value)
      // })

      return {
        // lengthsis,
        click,
        download,
        click1,
        click2,
        clickApp,
        Search,
        CirclePlus,
        Upload,
        Download,
        Delete,
        Check,
        Printer,
        CopyDocument,
        EditPen,
        Stamp,
      }
    },
  }
</script>
<style scoped>
  .toolbar-item {
    cursor: pointer;
    margin-bottom: 5px;
  }
</style>
